package com.lengtouzai.databaseexp.entity;

import io.jmix.core.entity.annotation.JmixGeneratedValue;
import io.jmix.core.metamodel.annotation.InstanceName;
import io.jmix.core.metamodel.annotation.JmixEntity;
import jakarta.persistence.*;

import java.util.UUID;

@JmixEntity
@Table(name = "EXP_FRIEND", indexes = {
        @Index(name = "IDX_EXP_FRIEND_FRIEND_GROUP", columnList = "FRIEND_GROUP_ID"),
        @Index(name = "IDX_EXP_FRIEND_TARGET", columnList = "TARGET_ID"),
        @Index(name = "IDX_EXP_FRIEND_USER", columnList = "USER_ID")
})
@Entity(name = "exp_Friend")
public class Friend {
    @JmixGeneratedValue
    @Column(name = "ID", nullable = false)
    @Id
    private UUID id;

    @Column(name = "VERSION", nullable = false)
    @Version
    private Integer version;

    @InstanceName
    @Column(name = "NICKNAME")
    private String nickname;

    @JoinColumn(name = "FRIEND_GROUP_ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private FriendGroup belongs;

    @JoinColumn(name = "TARGET_ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private User target;

    @JoinColumn(name = "USER_ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private User user;

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public User getTarget() {
        return target;
    }

    public void setTarget(User target) {
        this.target = target;
    }

    public FriendGroup getBelongs() {
        return belongs;
    }

    public void setBelongs(FriendGroup friendGroup) {
        this.belongs = friendGroup;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public UUID getId() {
        return id;
    }

    public void setId(UUID id) {
        this.id = id;
    }
}